Programming Languages Section

Lua

Card image
Post by Amina Delali, September 19th,2021

Some Facts

Lua is a lightweight embeddable scripting language. It is a functional imperative language that  can be used in different types of applications: video game development, 3D animations, and server side scripting.

It is also used in several projects as: Neovim ( a text editor ) and Adobe Photoshop Lightroom ( a cloud based service for photo editing and management). It is a cross platform language with an easy and readable syntax that makes it easy to learn.



How to install it

  • on Windows:

    To install Lua on Windows 10, just download and run the corresponding installer available in this GitHub releases page.

  • on ubuntu :

    First of all, you may already find Lua installed on your Ubuntu operating system. If it is not the case, just follow the next steps:

    1. open the terminal and run the following commands: sudo apt update
      sudo apt install
    2. after the second command, you will be prompted by the list of the available Lua versions. So, select the latest one and install it. At the time of writing this post, the latest Lua version is lua5.4. So, I had to run the following command to install it: sudo apt install lua5.4
    3. you may also end up with different Lua versions installed on your system. To set the default version of Lua (for example lua5.4), just do the following:
      1. edit the ~/.bashrc file and add this line: alias lua=/usr/bin/lua5.4
      2. and then on the terminal type in and run the following command: source ~/.bashrc
    4. now, to check the default installed version of lua just type and run the following command: lua -v

In the video below, the details of the installation of the Lualanguage on Ubuntu.

The Hello World Example

To run your first Lua code on Ubuntu, you can follow the next steps:

  1. in the Home folder, create the file “Hello.lua”.
  2. in that file write and save the following code:
    print ("Hello World!")

To run your code, just open the terminal from your Home folder and run the following command: lua Hello.lua



Additional Information

For more information about the language and the corresponding code, you can check the following pages:

Something to say ?

If you want to add something about the Lua language or about this post, please feel free to do it by commenting below 🙂 .